import type { Middleware } from '../context/types';

export const loggerMiddleware: Middleware = (key, value, next) => {
  console.groupCollapsed(`Context Update: ${key}`);
  console.log('Previous value:', value);
  console.log('New value:', value);
  console.groupEnd();
  next(value);
};

export const timestampMiddleware: Middleware = (_key, value, next) => {
  const timestampedValue = {
    value,
    timestamp: Date.now(),
    __timestamp: true,
  };
  next(timestampedValue);
};
